home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
os2
/
sysb091a.zip
/
sysbench
/
src
/
pmb_dive.c
< prev
next >
Wrap
Text File
|
1996-06-28
|
33KB
|
1,000 lines
// SysBench DIVE test module
// made for the warp II beta toolkit. Must probably be modified to run on OS/2 3.0
// corrected bug where paint_rot tried to paint horizontal lines not vertical 28/06/96
#define INCL_WIN
#define INCL_GPI
#define INCL_DOS
#include <os2.h>
#include <stdlib.h>
#include <string.h>
#define _MEERROR_H_
#include "mmioos2.h" /* It is from MMPM toolkit */
#include "dive.h"
#include "fourcc.h"
#include "pmb.h"
#include "types.h"
#define ID_WINDOW1 8000
#define PMB_DIVE_CLASS "SysBench dive winclass"
#define MIN_DIVE_TIME 10.0
#define MIN_DIVE2_TIME 1.0
#define MIN_MEASURE 0.1
#define MARGINAL 1.1
#define PI 3.14159265358979323846
//static HAB hab;
extern double cos(double);
extern double sin(double);
extern void err(char* s);
extern void warn(char* s);
extern void log(char* s);
//extern HAB anchorblock(void);
extern double rtime(void); // real time in seconds
extern double dtime(void); // used CPU time in seconds
extern double test_time;
void APIENTRY paint_videobw(ULONG unused);
void APIENTRY paint_rot(ULONG unused);
void APIENTRY paint_ms12(ULONG unused);
static MRESULT EXPENTRY DiveWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
static void Open(void *paintfun);
static void Close(void);
void end_Win(HDIVE hDive, char *p, HWND hwndClient);
void clr_lines(s32 y, s32 lines);
void disp_lines(u8* buf, s32 y, s32 lines);
_Inline void disp_lines2(u8* src, u8* dest, s32 yin, s32 yout);
_Inline s32 fun(s32 x, double param);
static HWND hwndClient = NULLHANDLE; /* Client area window handle */
static HWND hwndFrame = NULLHANDLE; /* Frame window handle */
static HMQ hmq;
static ULONG flCreate; /* Window creation control flags*/
static HAB bkHab;
static TID paint_tid;
static double result;
static char* framebuf; // the main framebuffer
static DIVE_CAPS dc;
static HDIVE hDive;
static RECTL rect;
static char szName[50];
static void Open(void *paintfun) {
s32 w,h, x,y;
RECTL rctl, rctlScreen;
QMSG qmsg; /* Message from message queue */
hwndClient = NULLHANDLE; /* Client area window handle */
hwndFrame = NULLHANDLE; /* Frame window handle */
// hab = anchorblock();
if ((bkHab = WinInitialize(0)) == 0L) /* Initialize PM */
err("Can't get anchor block handle for background thread");
if ((hmq = WinCreateMsgQueue( bkHab, 0 )) == 0L)/* Create a msg queue */
err("Can't create message queue for graphics test window");
if (!WinRegisterClass(bkHab, (PSZ)PMB_DIVE_CLASS, (PFNWP)DiveWindowProc, 0, 0)) {
err("DIVE test error: can't register class for child test window");
}
flCreate = FCF_TASKLIST;
if ((hwndFrame = WinCreateStdWindow(
HWND_DESKTOP, /* Desktop window is parent */
0, /* window styles */
&flCreate, /* Frame control flag */
PMB_DIVE_CLASS, /* Client window class name */
"SysBench dive test window", /* window text */
0, /* No special class style */
(HMODULE)0L, /* Resource is in .EXE file */
ID_WINDOW1, /* Frame window identifier */
&hwndClient /* Client window handle */
)) == 0L)
err("Can't create dive test window");
WinQueryWindowRect(HWND_DESKTOP, &rect);
WinSetWindowPos(hwndFrame, HWND_TOP, rect.xLeft, rect.yBottom,
rect.xRight-rect.xLeft+1, rect.yTop-rect.yBottom+1, SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER);
DosCreateThread(&paint_tid, (PFNTHREAD)paintfun, 0, 0, 64000);
while( WinGetMsg( bkHab, &qmsg, 0L, 0, 0 ) )
WinDispatchMsg( bkHab, &qmsg );
}
static void Close(void) {
WinDestroyWindow(hwndFrame); /* Tidy up... */
WinDestroyMsgQueue( hmq ); /* Tidy up... */
WinTerminate(bkHab);
}
double pmb_dive_bw(void) {
Open((void*)paint_videobw);
Close();
return result;
}
double pmb_dive_rot(void) {
Open((void*)paint_rot);
Close();
return result;
}
double pmb_dive_ms11(void) {
Open((void*)paint_ms12);
Close();
return result;
}
static MRESULT EXPENTRY
DiveWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
switch( msg )
{
case WM_CREATE:
break;
case WM_COMMAND:
break;
case WM_ERASEBACKGROUND:
return (MRESULT)( FALSE ); // TRUE -> yes, erase the background
case WM_PAINT:
{
HPS hps;
RECTL rc;
POINTL pt;
hps = WinBeginPaint( hwnd, 0L, &rc );
GpiSetColor( hps, CLR_BLACK ); // colour of the text,
GpiSetBackColor( hps, CLR_BLACK ); // its background and
GpiSetBackMix( hps, BM_OVERPAINT ); // how it mixes,
GpiSetMix( hps, FM_OVERPAINT ); // how it mixes,
// WinFillRect(hps, &rc, CLR_BLACK);
WinEndPaint( hps ); // Drawing is complete
break;
}
case WM_CLOSE:
WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );
break;
default:
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
return (MRESULT)FALSE;
}
void APIENTRY paint_videobw(ULONG unused) {
HPS hps;
POINTL p1, p2;
double t1, t2, test_time;
RECTL rc;
PVOID apa;
ULONG ret;
PDIVE_CAPS pdc;
s32 i, j, c, runs, runs_10, framesize, sh, scanlen, frames, numApertures, ApertureNum, Datalen, Offset, ApertureOffset, RemainLen, z;
char* framecopy;
char* framecopy1;
APIRET rc1 = 0UL;
memset(&dc, 0, sizeof(dc));
dc.ulStructLen = sizeof(dc);
dc.ulFormatLength = 0;
ret = DiveQueryCaps(&dc, DIVE_BUFFER_SCREEN);
if (DIVE_SUCCESS != ret) {
if (ret == DIVE_ERR_INSUFFICIENT_LENGTH) {
dc.pFormatData = calloc(dc.ulFormatLength,1);
ret = DiveQueryCaps(&dc, DIVE_BUFFER_SCREEN); // let's try again
if (DIVE_SUCCESS != ret) {
err("Error in call to DiveQueryCaps()");
}
} else {
err("Error in call to DiveQueryCaps()");
}
}
rc1 = DiveOpen(&hDive, FALSE, &apa);
if (rc1 != DIVE_SUCCESS)
{
if (rc1 == DIVE_ERR_TOO_MANY_INSTANCES)
{
log("Dive error - too many instances");
result = -1;
}
if (rc1 == DIVE_ERR_SSMDD_NOT_INSTALLED)
{
log("Dive error - SSMDD.SYS not installed");
result = -1;
}
if (rc1 == DIVE_ERR_NO_DIRECT_ACCESS)
{
log("Dive error - no direct access");
result = -1;
}
if (rc1 == DIVE_ERR_ALLOCATION_ERROR)
{
log("Dive error - allocation error, check MMOS/2 installed");
result = -1;
}
if (rc1 != DIVE_SUCCESS)
{
result = -1;
free(dc.pFormatData);
WinPostMsg( hwndClient, WM_QUIT, (MPARAM)0,(MPARAM)0 );
return;
}
}
framebuf = (char*)apa;
WinQueryWindowRect(HWND_DESKTOP, &rect);
ret = DiveAcquireFrameBuffer(hDive, &rect);
if (ret != DIVE_SUCCESS)
{
log("Error in DiveAcquireFrameBuffer()");
result = -1;
end_Win(hDive,dc.pFormatData,hwndClient);
return;
}
framesize = dc.ulVerticalResolution * dc.ulScanLineBytes;
framecopy = malloc(framesize);
if (framecopy == null) {
log("Can't get memory for copy of frame buffer");
result = -1;
end_Win(hDive,dc.pFormatData,hwndClient);
return;
}
if (dc.fScreenDirect)
{ /* if direct access allowed */
if (dc.ulApertureSize >= framesize)
{ /* and if video buffer larger or equal to our buffer */
memcpy(framecopy, framebuf, framesize); /* copy from video buffer to ours */
}
else
{